package ui;

import io.GPSPoint;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import session.Session;
import actions.FileChooser;
import actions.QuitAction;

public class GPSFrame extends JFrame {
	
	Map<String, List<GPSPoint>> gpsTracks = new HashMap<String, List<GPSPoint>>();
	
	private CoordinatedPanel coordinatePanel; 
	
	public GPSFrame()  {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
		Session session = new Session();
		
		JMenuBar mb = new JMenuBar();
		JMenu fileMenu = new JMenu("File");
		fileMenu.setMnemonic('F');
		mb.add(fileMenu);
		
		//Open File Action
		JMenuItem mi = new JMenuItem("Open GPS File...");
		mi.setMnemonic('O');
		mi.addActionListener(new FileChooser(this));
		fileMenu.add(mi);
		//Quit Action
		JMenuItem mq = new JMenuItem("Exit");
		mq.setMnemonic('x');
		mq.addActionListener(new QuitAction());
		fileMenu.add(mq);
		setJMenuBar(mb);

		coordinatePanel = new CoordinatedPanel(gpsTracks, session);
		setContentPane(coordinatePanel); 
		setSize(600, 850);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	
	
	public static void main(String[] args) throws Exception {
		new GPSFrame();
	}

}